/**
 * @file rank/popularize/luogu1029/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/8 10:47:45
 **/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
  // High rating and good luck!
  ll x, y;
  cin >> x >> y;
  ll prod = x * y;
  int ans = 0;
  if (x == y) ans--;  // ?
  for (int i = 1; i <= prod / i; ++i)
    if (prod % i == 0 && gcd(i, prod / i) == y) ans += 2;
  cout << ans << endl;

  return 0;
}
